from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import QMainWindow, QMessageBox


class ForScreenShot(QMainWindow):
    def __init__(self, parent=None):
        super(ForScreenShot, self).__init__(parent)
        QTimer.singleShot(500, self.make_screenshot)

    def make_screenshot(self):
        screen = self.app.primaryScreen()
        screenshot = screen.grabWindow(self.winId())
        screenshot.save('1.png', 'png')
        msg = QMessageBox()
        msg.setIcon(QMessageBox.Information)
        msg.setText("Screenshot saved.")
        msg.setWindowTitle("Information")
        msg.exec_()
        self.close()
